const fs = require('fs');

const jsonData = {
  "errorKnowList": [
    {
      "id": 15,
      "protocolid": 1,
      "protocolName": "tag",
      "name": "id为18855885",
      "error": "tag",
      "description": "tag",
      "matchContent": 1,
      "tag": "tag",
      "platform": "tag"
    },
    {
      "id": 1,
      "protocolid": 1,
      "protocolName": "tag",
      "name": "tag",
      "error": "tag",
      "description": "tag",
      "matchContent": 1,
      "tag": "tag",
      "platform": "tag"
    },
    {
      "id": 123,
      "protocolid": 1,
      "protocolName": "tag",
      "name": "tag1",
      "error": "tag",
      "description": "tag",
      "matchContent": 1,
      "tag": "tag",
      "platform": "tag"
    },
    {
      "id": 2,
      "protocolid": 1,
      "protocolName": "tag",
      "name": "tag2",
      "error": "tag",
      "description": "tag",
      "matchContent": 1,
      "tag": "tag",
      "platform": "tag"
    },
    {
      "id": 124,
      "protocolid": 1,
      "protocolName": "tag",
      "name": "tag2",
      "error": "tag",
      "description": "tag",
      "matchContent": 1,
      "tag": "tag",
      "platform": "tag"
    },
    {
      "id": 13,
      "protocolid": 1,
      "protocolName": "tag",
      "name": "tag3",
      "error": "tag",
      "description": "tag",
      "matchContent": 1,
      "tag": "tag",
      "platform": "tag"
    },
    {
      "id": 12,
      "protocolid": 1,
      "protocolName": "tag",
      "name": "tag4",
      "error": "tag121",
      "description": "tag",
      "matchContent": 1,
      "tag": "tag",
      "platform": "tag"
    },
    {
      "id": 14,
      "protocolid": 1,
      "protocolName": "tag",
      "name": "tag5",
      "error": "1tag",
      "description": "tag",
      "matchContent": 1,
      "tag": "tag",
      "platform": "tag"
    }
  ],
  "totalElements": 8,
  "ids": 0
};

const originalArray = jsonData.errorKnowList;
const newObjects = [];

for (let i = 0; i < 2000; i++) {
  newObjects.push({
    id: i + originalArray.length + 1,
    protocolid: 1,
    protocolName: "tag",
    name: `newTag${i}`,
    error: "tag",
    description: "tag",
    matchContent: 1,
    tag: "tag",
    platform: "tag"
  });
}

jsonData.errorKnowList = originalArray.concat(newObjects);

// 将更新后的JSON数据写入到名为updated_data.json的文件中
fs.writeFile('D:/errorKnowledge2.json', JSON.stringify(jsonData, null, 2), (err) => {
  if (err) {
    console.error(err);
  } else {
    console.log('数据已成功写入updated_data.json文件');
  }
});
